package student;

import student.StudentEntity;

import javax.persistence.*;

public class UpdateStudent {
    public static void main(String args[]) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("Student_details");
        EntityManager em = emf.createEntityManager();

        StudentEntity s = em.find(StudentEntity.class, 1001);
        System.out.println("修改前");
        System.out.println("Student id = " + s.getS_id());
        System.out.println("Student Name = " + s.getS_name());
        System.out.println("Student Age = " + s.getS_age());

        s.setS_age(21);

        System.out.println("修改后");
        System.out.println("Student id = " + s.getS_id());
        System.out.println("Student Name = " + s.getS_name());
        System.out.println("Student Age = " + s.getS_age());
    }
}
